package com.xiaojf.xlog.appender.console.configure;

import com.xiaojf.xlog.appender.AccessLogAppender;
import com.xiaojf.xlog.appender.console.AccessLogConsoleAppender;
import com.xiaojf.xlog.aspect.AccessLogAspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * rdb 保存访问日志配置
 *
 * @author Ade.Xiao 2021/3/12 13:42
 */
@Configuration
@ConditionalOnMissingBean(AccessLogAppender.class)
@ConditionalOnProperty(prefix = "xlog.access", name = "appender-type", havingValue = "console", matchIfMissing = true)
public class AccessLogConsoleAppenderConfigure {
    /**
     * 控制台方式记录访问日志 ， 默认方式
     *
     * @return {@link AccessLogAspect}
     * @author Ade.Xiao 2021-03-11 14:36:19
     */
    @Bean
    @Primary
    public AccessLogAppender accessLogAppender() {
        return new AccessLogConsoleAppender();
    }
}
